#从数据库中查询IP对应的地址
import subprocess

def main():
	f = open('./result/ip6_addr_s2d_norepeat.txt','r')
	f_new = open('./result/ipv6_location_s2d.csv','w')
	while True:
		ip = f.readline().replace('\n','')
		if len(ip)==0:
			break
		else:
			t_ip = ip.split(',')
		txt1 = subprocess.getoutput("python3 ipdb.py "+t_ip[0]).split(' ')[1]
		txt2 = subprocess.getoutput("python3 ipdb.py "+t_ip[1]).split(' ')[1]
		f_new.write(txt1+','+txt2+'\n')
	f.close()
	f_new.close()

main()

